
import hashlib ## 引入加密模块
from django.conf import settings
import uuid
def md5(string):
    """MD5加密"""
    hash_object = hashlib.md5(settings.SECRET_KEY.encode('utf-8'))
    hash_object.update(string.encode('utf-8'))
    return hash_object.hexdigest()

# 随机生成上传桶的文件名，先通过uuid生成随机的字符串，再返回这个随机字符串的md5加密的值
def uid(string):
    data = "{}-{}".format(str(uuid.uuid4()),string)
    return md5(data)

# 随机字符串的函数
def vid(string):
    data = "{}--{}".format(str(uuid.uuid4()),string)
    return md5(data)







